/**
 * 
 */
package xj.toolkit.bean.xip.test;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import xj.toolkit.bean.bytebean.core.BeanFieldCodec;
import xj.toolkit.util.ByteUtils;

/**
 * @author hp
 *
 */
public class XipDemo {

	public static void main(String[] args) {
		AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
				"xj/toolkit/bean/xip/test/xipDemo2.xml");

		BeanFieldCodec xipBeanCodec = (BeanFieldCodec) ctx.getBean("beanCodec");

		SampleSsip ssip = new SampleSsip();

		ssip.setName("乌克兰安东诺夫打包来重庆了");
		ssip.setAge(12);
		ssip.setHeight(1.86f);

		byte[] bytesBody = xipBeanCodec.encode(xipBeanCodec
				.getEncContextFactory().createEncContext(ssip, ssip.getClass(),
						null));

		System.out.println(ByteUtils.bytesAsHexString(bytesBody, 1024));

		System.out.println(xipBeanCodec.decode(xipBeanCodec
				.getDecContextFactory().createDecContext(bytesBody,
						SampleSsip.class, null, null)).getValue());
		
		ctx.close();

	}
}
